
package view;

import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;

import view.TelaInicial;
/**
 *
 * @author Wesley
 */
public class TelaLogin extends javax.swing.JFrame {
    
    TelaInicial telaInicial = new TelaInicial();

    public TelaLogin() {
        initComponents();
    }

   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelSejaBemViendo = new javax.swing.JLabel();
        labelIdentificacao = new javax.swing.JLabel();
        labelLogin = new javax.swing.JLabel();
        labelSenha = new javax.swing.JLabel();
        botaoEntrar = new javax.swing.JButton();
        botaoCancelar = new javax.swing.JButton();
        campoSenha = new javax.swing.JPasswordField();
        campoLogin = new javax.swing.JTextField();
        wallpaper = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);
        setLocationByPlatform(true);
        setResizable(false);
        setType(java.awt.Window.Type.UTILITY);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        getContentPane().setLayout(null);

        labelSejaBemViendo.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
        labelSejaBemViendo.setForeground(new java.awt.Color(255, 255, 255));
        labelSejaBemViendo.setText("Seja Bem Vindo ");
        getContentPane().add(labelSejaBemViendo);
        labelSejaBemViendo.setBounds(30, 10, 660, 70);

        labelIdentificacao.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        labelIdentificacao.setForeground(new java.awt.Color(255, 255, 255));
        labelIdentificacao.setText("Identificação ______________");
        getContentPane().add(labelIdentificacao);
        labelIdentificacao.setBounds(470, 340, 220, 40);

        labelLogin.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        labelLogin.setForeground(new java.awt.Color(255, 255, 255));
        labelLogin.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        labelLogin.setText("Usuario:");
        getContentPane().add(labelLogin);
        labelLogin.setBounds(400, 380, 60, 26);

        labelSenha.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        labelSenha.setForeground(new java.awt.Color(255, 255, 255));
        labelSenha.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        labelSenha.setText("Senha:");
        getContentPane().add(labelSenha);
        labelSenha.setBounds(410, 420, 50, 30);

        botaoEntrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/TelaLoginIconEntrar.jpg"))); // NOI18N
        botaoEntrar.setText("Entrar");
        botaoEntrar.setFocusPainted(false);
        botaoEntrar.setFocusable(false);
        botaoEntrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoEntrarActionPerformed(evt);
            }
        });
        getContentPane().add(botaoEntrar);
        botaoEntrar.setBounds(470, 460, 110, 30);

        botaoCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/TelaLoginIconCancelar.jpg"))); // NOI18N
        botaoCancelar.setText("Cancelar");
        botaoCancelar.setFocusPainted(false);
        botaoCancelar.setFocusable(false);
        botaoCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoCancelarActionPerformed(evt);
            }
        });
        getContentPane().add(botaoCancelar);
        botaoCancelar.setBounds(580, 460, 110, 30);

        campoSenha.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        campoSenha.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(campoSenha);
        campoSenha.setBounds(470, 420, 220, 30);

        campoLogin.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        campoLogin.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        campoLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoLoginActionPerformed(evt);
            }
        });
        getContentPane().add(campoLogin);
        campoLogin.setBounds(470, 380, 220, 30);

        wallpaper.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/TelaLoginImageWallpaper.jpg"))); // NOI18N
        wallpaper.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        getContentPane().add(wallpaper);
        wallpaper.setBounds(-310, -130, 1040, 680);

        setSize(new java.awt.Dimension(716, 539));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void campoLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoLoginActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoLoginActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        
        telaInicial.setEnabled(false);
        telaInicial.setFocusableWindowState(false);
        telaInicial.setVisible(true);
        
    }//GEN-LAST:event_formWindowOpened

    private void botaoEntrarActionPerformed(java.awt.event.ActionEvent evt) {//area de autenticacao
        if(campoLogin.getText().equals("ads")&& (campoSenha.getText().equals("ads"))){
            /*JOptionPane.showMessageDialog(null,
                    "Usuario logado com sucesso!!! Bem Vindo: "+campoLogin.getText().toUpperCase()+"!!!",
                    "Autenticação",
                    JOptionPane.INFORMATION_MESSAGE);*/
        
            this.dispose();
            
            telaInicial.setEnabled(true);
            telaInicial.setFocusableWindowState(true);
            telaInicial.requestFocus();
            
        }
        else{
            JOptionPane.showMessageDialog(null,
                    "Usuario ou Senha Invalida... Por favor entre em contato com o Admisnistrador do Sistema!!!",
                    "Autenticação",
                    JOptionPane.ERROR_MESSAGE);
        }//menssagem cliente logando errado
    }
    
    private void botaoCancelarActionPerformed(java.awt.event.ActionEvent evt) {//botao de cancelar acesso e sair do sistema
        System.exit(0);
    }                                               
/*
    public static void main(String args[]) {

        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaLogin().setVisible(true);
            }
        });
    }
*/  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoCancelar;
    private javax.swing.JButton botaoEntrar;
    private javax.swing.JTextField campoLogin;
    private javax.swing.JPasswordField campoSenha;
    private javax.swing.JLabel labelIdentificacao;
    private javax.swing.JLabel labelLogin;
    private javax.swing.JLabel labelSejaBemViendo;
    private javax.swing.JLabel labelSenha;
    private javax.swing.JLabel wallpaper;
    // End of variables declaration//GEN-END:variables
}
